package com.ktwlsoft.archivemanage.service.utils;

/**
 * StringUtil
 *
 * @author zhuhe on 2019/10/25 11:25
 * @version 1.0
 */
public class StringUtil {

    /**
     * 检测是否包含数字:0否,1是 on 2019/10/25 11:15
     *
     * @param s s
     * @return boolean
     */
    public static boolean isDigit(String s){
        boolean b = false;
        for (int i = 0; i < s.length(); i++) {
            if (Character.isDigit(s.charAt(i))) {
                b =  true;
                break;
            }
        }
        return b;
    }

    /**
     * 检测是否包含字母:0否,1是 on 2019/10/25 11:15
     *
     * @param s s
     * @return boolean
     */
    public static boolean isLetter(String s){
        boolean b = false;
        for(int i = 0;i < s.length();i++){
            char x = s.charAt(i);
            if((x >= 'a' && x <= 'z' )||( x >= 'A'&& x <= 'Z') ){
                b = true;
                break;
            }
        }
        return b;
    }

    /**
     * 检测是否包含特殊字符:0否,1是 on 2019/10/25 11:15
     *
     * @param s s
     * @return boolean
     */
    public static boolean isSpecialCharacters(String s) {
        if(s.replaceAll("[\u4e00-\u9fa5]*[a-z]*[A-Z]*\\d*-*_*\\s*", "").length() == 0){
            return false;
        }
        return true;
    }
}